This is a live demo of the wrapping method SpriteWorld uses for its scrolling. It lets you go behind the scenes and see what happens in the offscreen area during a scrolling animation. As with many of the demos, you can move around using either the arrow keys or the numeric keypad. At any time you can press Esc to return to the beginning of the maze, and the mouse button quits the program.
In the top of the window, what you would normally see on the screen is displayed, and in the bottom, the offscreen "work area" of the SpriteWorld is shown. In addition, color-coded rectangles show which "pieces" are copied from the offscreen area to the screen area. Of course, you wouldn't see these rectangles in a normal animation; they are provided here only to demonstrate how the scrolling routines work. You can change the rectangles' thickness by hitting the 0-5 number keys. (Not the ones on the keypad.)
Note that this is not a good demonstration of the speed of the scrolling routines, since this program not only copies two different portions to the screen each frame, but also copies the entire background to the work area to erase the color-coded rectangles from the previous frame, which slows things down considerably. (It does this by calling SWFlagScrollingRectAsChanged.)
The other sprites bouncing around the screen have been added to demonstrate what happens "behind the scenes" when a sprite moves into the visible rectangle which the user sees on the screen. You'll notice that only the portion of the sprite that is visible in the top portion of the window is drawn offscreen, since the sprite is clipped to the visScrollRect. Also, several idle sprites have been added at the beginning of the maze. This is so you can see how idle sprites are handled as they enter and exit the visScrollRect.
Technical Information
The demo installs a PostDrawCallBack to draw the color-coded rectangles in the work area each frame. It then copies the work area to a custom WindowFrame created specifically for this purposes. (See CreateSpriteWorld.) Since this WindowFrame is completely separate from the SpriteWorld, it must be locked with SWLockWindowFrame, since SWLockSpriteWorld will only lock that which is part of the SpriteWorld.
The TileMap is "hard-coded" as an array, since I built this demo before making the SWLoadTileMap and SWSaveTileMap routines. To use the data in the array, simply create a TileMap as usual, and then copy the array data into it. See CreateSpriteWorld in Illustration.c to see how this works.